package site.qianli.discover.web.thread;

import java.lang.reflect.Method;

public class ClassB {
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public void callback(String methodName) {
		String className = "";
		StackTraceElement[] traces = Thread.currentThread().getStackTrace();
		String thisTrace = this.getClass().getName() + ".callback";
		for (StackTraceElement trace : traces) {
			if (trace.toString().equals(thisTrace)) {
				break;
			}
			className = trace.getClassName();
		}
		try {
			Class clazz = Class.forName(className);
			Method method = clazz.getMethod(methodName, new Class[0]);
			Object obj = clazz.newInstance();
			method.invoke(obj, new Object[0]);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println(className);
	}

}
